﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using ELMWCFServiceClass.ELMWCF;

namespace SettingModule.Views.FieldSettingView
{
    public partial class CW_FieldAdd : ChildWindow
    {
        public CW_FieldAdd(IFieldSettingPresentationModel model)
        {
            InitializeComponent();
           this.DataContext= this.model = model;
           
        }
        private IFieldSettingPresentationModel model;
        //private ELMServiceClient _domaincontext;
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(txtName.Text))
            {
                MessageBox.Show("字段名称不能为空！");
                return;
            }
            if (cbGroups.SelectedIndex == -1)
            {
                MessageBox.Show("请选择字段分组！");
                return;
            }
            if (cbTypes.SelectedIndex == -1)
            {
                MessageBox.Show("请选择字段类型！");
                return;
            }
            t_FieldGroup group = (t_FieldGroup)cbGroups.SelectedItem;
            t_FieldType type = (t_FieldType)cbTypes.SelectedItem;
            model.AddField(txtName.Text.Trim(),group.FieldGroupId,type.FieldTypeId);
            this.DialogResult = true;
            
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }
    }
}

